package com.deliveryservicesystem.service.impl;

import com.deliveryservicesystem.dataaccess.DatabaseConnection;
import com.deliveryservicesystem.model.Delivery;
import com.deliveryservicesystem.service.ServiceTemplate;
import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import oracle.jdbc.OracleTypes;

/**
 * File Name: CustomerServiceImpl.java
 * Version:
 * Description:
 * Package: com.deliveryservicesystem.service.impl
 * Author: Lance
 * Date: Jun 19, 2012
 * Editor:
 */
public class DeliveryServiceImpl extends GeneralServicesImpl implements ServiceTemplate<Delivery>
{

    @Override
    public ResultSet getAllTableData() throws SQLException
    {
        DatabaseConnection databaseConnection = DatabaseConnection.getInstance();
        Connection connection = databaseConnection.getConnection();
        CallableStatement prepareCall = connection.prepareCall("BEGIN ? := GET_DATA.DELIVERIES; END;");
        prepareCall.registerOutParameter(1, OracleTypes.CURSOR);
        prepareCall.execute();
        ResultSet resultSet = (ResultSet) prepareCall.getObject(1);
        return resultSet;
    }
}